using System;
using System.Collections;
using Flaschengeist.DataAccess;
using Flaschengeist.Entities;
using UnityEngine;

namespace Flaschengeist.Processes 
{
	public class SubmitScore : MonoBehaviour
	{
		private XmlRpc xmlrpc;
		
		// Use this for initialization
		public void Start()
		{
			xmlrpc = gameObject.AddComponent<XmlRpc>();
			xmlrpc.Completed += (val) => Completed();
		}
		
		public void Process(ScoreItem scoreItem)
		{
			Debug.Log("Submit Score " + scoreItem.Score);
			var parameter = new Hashtable();
			parameter.Add("Name", scoreItem.PlayerName);
			parameter.Add("Score", scoreItem.Score);
			xmlrpc.Process("insertScore", parameter);
		}
		
		public event Action Completed;
	}
}

